
#pragma once

#include "zen_vap.h"
#include "MySprite.h"

using namespace Zen;
using namespace Zen::Vap;

class BGLayer : public Combination2D
{
public:
	BGLayer()
	{
	}

	void load() override
	{
		auto & r = gConfig.ra;
		auto const size = gConfig.size;

		auto d = std::make_shared<FigureColors>();
		this->addNode(d);

		auto content = std::make_shared<FigureColorsContent>();

		float dx = 100.f / size.w;
		float dy = 100.f / size.h;
		for(float i = dx; i < 1; i += dx)
		{
			FigureColorsContent::VertexData vd[2] = {
				{ {i, 0}, Color4f(r.next() | 0x777777ff) },
				{ {i, 1}, Color4f(r.next() | 0x777777ff) },
			};
			content->addVertexes(vd, 2);
		}
		for(float i = dy; i < 1; i += dy)
		{
			FigureColorsContent::VertexData vd[2] = {
				{ { 0, i}, Color4f(r.next() | 0x777777ff) },
				{ {1, i}, Color4f(r.next() | 0x777777ff) },
			};
			content->addVertexes(vd, 2);
		}
		
		d->setFigureContent(content);
		d->setLineMode(true);
	}
};
